package de.hauschild.gmltracer.gml.impl.value.integer;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;

public abstract class OneIntegerOperatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final IntegerToken value = tokenStack.pop(IntegerToken.class);

    final Integer result = compute(value.getValue());
    tokenStack.push(new IntegerToken(result));
  }

  protected abstract Integer compute(final Integer value);

}
